﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.Tool.UndoRedoHistory"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" Width="900" Height="600" Background="AliceBlue">

    <UserControl.Resources>
        <Converter:CalcConverter CalcType="Sub" ValueRight="50" x:Key="RemoveMargin"/>
        <Converter:CalcConverter CalcType="Div" ValueRight="2" x:Key="DivThree"/>


        <Style  TargetType="{x:Type s:SurfaceButton}" BasedOn="{StaticResource {x:Type s:SurfaceButton}}">
            <Setter Property="Width" Value="48"/>
            <Setter Property="Height" Value="48"/>
        </Style>
    </UserControl.Resources>
    <Grid  Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition Width="20"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Grid.ColumnSpan="3" Background="White">

            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <s:SurfaceButton Margin="5" Grid.Column="0" Background="{StaticResource IconUndo }" Click="OnUndoClick" IsEnabled="{Binding Path=ScrumData.DataContext.UndoManager.CanUndo}"/>
            <s:SurfaceButton Margin="5" Grid.Column="1" Background="{StaticResource IconDeleteUndoStack }" Click="DeleteUndoStack"  />
            <s:SurfaceButton Margin="5" Grid.Column="2" Background="{StaticResource IconRedo }" Click="OnRedoClick"  IsEnabled="{Binding Path=ScrumData.DataContext.UndoManager.CanRedo}" />
        </Grid>
        <Grid Background="White"  Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>            
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" BorderBrush="Black" BorderThickness="0"  Margin="0,0,2,0" Background="White" >
                <Label Content="{Localization:Translate Uid=Undo_Text_Undo, Default=[Undo]}" Margin="0" Grid.Column="1"  HorizontalContentAlignment="Left" VerticalAlignment="Center"  FontSize="12" FontWeight="Bold" >
                </Label>
            </Border>
            <Border Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,0,0" Background="White" >
                <Label Content="{Localization:Translate Uid=Undo_Text, Default=[Undo]}" Margin="0" Grid.Column="1"  HorizontalContentAlignment="Left" VerticalAlignment="Center"  FontSize="12" FontWeight="Bold" >
                </Label>
            </Border>
        </Grid>
        <Grid Background="White"  Grid.Row="1" Grid.Column="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>

            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" BorderBrush="Black" BorderThickness="0"  Margin="0,0,2,0" Background="White" >
                <Label Content="{Localization:Translate Uid=Undo_Text_Redo, Default=[Redo]}" Margin="0" Grid.Column="1"  HorizontalContentAlignment="Left" VerticalAlignment="Center"  FontSize="12" FontWeight="Bold" >
                </Label>
            </Border>
            <Border Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,0,0" Background="White" >
                <Label Content="{Localization:Translate Uid=Undo_Text, Default=[Redo]}" Margin="0"  Grid.Column="1"  HorizontalContentAlignment="Left" VerticalAlignment="Center"  FontSize="12" FontWeight="Bold" >
                </Label>
            </Border>

        </Grid>
        <s:SurfaceScrollViewer x:Name="ScrollerListUndo" Grid.Row="2" Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <s:SurfaceListBox Background="{StaticResource ListBoxBackgroundGrayHorizontalInvert}" x:Name="ListUndo" ItemsSource="{Binding ScrumData.DataContext.UndoManager.UndoStack}" SelectionMode="Single"  SelectionChanged="OnUndoListClick" >
                <s:SurfaceListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid HorizontalAlignment="Stretch" x:Name="GridUndo" MinWidth="{Binding ElementName=ScrollerListRedo, Path=ActualWidth}" MaxWidth="{Binding ElementName=ScrollerListUndo, Path=ActualWidth}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding ElementName=GridUndo, Path=MinWidth, Converter={StaticResource DivThree}}"/>
                                <ColumnDefinition Width="{Binding ElementName=GridUndo, Path=MinWidth, Converter={StaticResource DivThree}}"/>                          
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" FontSize="12" Text="{Binding ElementName}" TextWrapping="Wrap" HorizontalAlignment="Left"/>
                            <TextBlock Grid.Column="1" FontSize="12"  Text="{Binding Cause}" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0" Padding="0"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </s:SurfaceListBox.ItemTemplate>
            </s:SurfaceListBox>
        </s:SurfaceScrollViewer>

        <s:SurfaceScrollViewer x:Name="ScrollerListRedo" Grid.Row="2" Grid.Column="2"  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <s:SurfaceListBox Background="{StaticResource ListBoxBackgroundGrayHorizontalInvert}" x:Name="ListRedo" ItemsSource="{Binding ScrumData.DataContext.UndoManager.RedoStack}" SelectionMode="Single"  SelectionChanged="OnRedoListClick">
                <s:SurfaceListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid HorizontalAlignment="Stretch" x:Name="GridRedo" MinWidth="{Binding ElementName=ScrollerListRedo, Path=ActualWidth}" MaxWidth="{Binding ElementName=ScrollerListRedo, Path=ActualWidth}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding ElementName=GridRedo, Path=MinWidth, Converter={StaticResource DivThree}}"/>
                                <ColumnDefinition Width="{Binding ElementName=GridRedo, Path=MinWidth, Converter={StaticResource DivThree}}"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" FontSize="12" Text="{Binding ElementName}" TextWrapping="Wrap" HorizontalAlignment="Left"/>
                            <TextBlock Grid.Column="1" FontSize="12"  Text="{Binding Cause}" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0" Padding="0"></TextBlock>
                        </Grid>
                    </DataTemplate>
                </s:SurfaceListBox.ItemTemplate>
            </s:SurfaceListBox>
        </s:SurfaceScrollViewer>

    </Grid>
</UserControls:ScrumUserControl>
